# Contributor: Carlo Landmeter <clandmeter@gmail.com>
# Maintainer: Justin Berthault <justin.berthault@zaclys.net>
pkgname=micro
pkgver=2.0.6
pkgrel=0
# This will need to be updated along with version as it cannot currently be
# obtained from the tarball, and is necessary if the user is to make error
# reports upsteam.
_commithash=60846f549ccd02598dea5889992f1e4cddc8e86d
pkgdesc="A modern and intuitive terminal-based text editor"
url="https://micro-editor.github.io/"
options="!check chmod-clean"
arch="all !mips !mips64" # go is missing
license="MIT"
makedepends="go"
subpackages="$pkgname-doc"
source="micro-$pkgver.tar.gz::https://github.com/zyedidia/micro/archive/v$pkgver.tar.gz"
builddir="$srcdir/src/github.com/zyedidia/$pkgname"

prepare() {
	mkdir -p ${builddir%/*}
	mv "$srcdir"/$pkgname-$pkgver "$builddir"/
	default_prepare
}

build() {
	export GOPATH="$srcdir"
	go get -v -ldflags "
		-s -w
		-X github.com/zyedidia/micro/v2/internal/util.Version=$pkgver-$pkgrel
		-X github.com/zyedidia/micro/v2/internal/util.CommitHash=$_commithash
		-X github.com/zyedidia/micro/v2/internal/util.CompileDate=$SOURCE_DATE_EPOCH
		" \
		./cmd/micro
}

package() {
	install -Dm755 "$srcdir"/bin/$pkgname "$pkgdir"/usr/bin/$pkgname
	install -Dm644 "$builddir"/assets/packaging/micro.1 -t "$pkgdir"/usr/share/man/man1
	install -Dm644 "$builddir"/assets/packaging/micro.desktop -t "$pkgdir"/usr/share/applications
	install -Dm644 "$builddir"/assets/micro-logo.svg "$pkgdir"/usr/share/pixmaps/micro.svg
	install -Dm644 "$builddir"/assets/micro-solarized.png "$pkgdir"/usr/share/pixmaps/micro.png
}

sha512sums="d0ea4b43620586dc4994eff5256bfa9869d34557bec341a8e953b93f45a9e274cb1017f75da2398f5dc1c60e701d7d1ae6f08f6c899356d0ba3d811a720b3cb1  micro-2.0.6.tar.gz"
